package com.jy.shorturl.util;

import java.net.HttpURLConnection;
import java.net.URL;

public class SourceUrlIsLegal {
	
	public static String IsLegeal(String SourceUrl){
		 int status = 404;
		  try {
		   URL urlObj = new URL(SourceUrl);
		   HttpURLConnection oc = (HttpURLConnection) urlObj.openConnection();
		   oc.setUseCaches(false);
		   oc.setConnectTimeout(3000); // 设置超时时间
		   status = oc.getResponseCode();// 请求状态
		   if (200 == status) {
		    // 200是请求地址顺利连通。。
		    return "Y";
		   }
		  } catch (Exception e) {
		   e.printStackTrace();
		  }
		  return "N";
	}
	
}
